<?php
/*
 * Copyright (c) 2021.  Liuhongbin All rights reserved.
 * @domain http://dkyx.cc
 * @author liuhongbin <514660094@qq.com>
 */

namespace hiduoke\services\sms\driver;


use hiduoke\base\BaseSms;

class Aliyun extends BaseSms
{


    protected function initialize(array $config)
    {
        parent::initialize($config);
        $this->name = 'aliyun';
    }

    public function app()
    {
        $gateways_config = array(
            'access_key_id'     => $this->config['aliyun_id'], // SDK APP ID
            'access_key_secret' => $this->config['aliyun_secret'], // APP KEY
            'sign_name'         => $this->config['aliyun_sign'], // 短信签名，如果使用默认签名，该字段可缺省（对应官方文档中的sign）
        );
        return $this->setGateways($this->name, $gateways_config);
    }

    public function send($to, $message)
    {
        $res = $this->app()->send($to, $message);
        return $res[$this->name];
    }
}